<template>
  <div class="music">
    <!-- 语音播放功能 -->
    <div>
      <!-- <input type="button" id="tts_btn" @click="myplay(0)" value="播放"> -->
    </div>
    <div id="bdtts_div_id">
      <audio id="roll" autoplay="autoplay">
        <source
          id="tts_source_id"
          src="../../assets/audio/roll.mp3"
          type="audio/mpeg"
        />
      </audio>
      <audio id="celebrate" autoplay="autoplay">
        <source
          id="tts_source_id"
          src="../../assets/audio/victory.mp3"
          type="audio/mpeg"
        />
      </audio>
    </div>
  </div>
</template>

<script>
export default {
  name: "myplaymp3",
  data() {
    return {};
  },
  methods: {
    myplay(action) {
      console.log("#mp3pay");
      switch (action) {
        case 1:
          var ttsAudio = document.getElementById("roll");
          ttsAudio.currentTime = 0
          ttsAudio.play();
          break;
        case 2:
          var ttsAudio = document.getElementById("celebrate");
          ttsAudio.play();
          break;
        default:
          break;
      }
    },
    stop(action) {
      console.log("#stop");
      switch (action) {
        case 1:
          var ttsAudio = document.getElementById("roll");
          ttsAudio.pause();
          break;
        case 2:
          var ttsAudio = document.getElementById("celebrate");
          ttsAudio.pause();
          break;
        default:
          break;
      }
    }
  },
};
</script>

<style>
/* .listen {
     position:fixed;
      right:10px;
      bottom:10px;
      // top:20px;
      z-index:9999;
     } */
</style>
